#include<bits/stdc++.h>
using namespace std;
const int N=1e3+5,mod=1e9+7;
long long n,m,dp[N][N][2],g[N][N][2],a[N],w[2],jc[N],inv[N];
long long ksm(long long i,long long j)
{
	i%=mod;
	long long ans=1;
	while(j)
	{
		if(j%2==1) ans=(ans*i)%mod;
		i=(i*i)%mod;
		j/=2;
	}
	return ans;
}
long long aa(long long i,long long j)
{
	return jc[i]*inv[i-j]%mod;
}
int main()
{
	freopen("game.in","r",stdin);
	freopen("game.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m;
	for(int i=1;i<=n;++i)
		cin>>a[i];
	jc[0]=inv[0]=1;
	for(int i=1;i<=n;++i)
		jc[i]=jc[i-1]*i%mod;
	inv[n]=ksm(jc[n],mod-2);
	for(int i=n-1;i>=1;--i)
		inv[i]=(inv[i+1]*(i+1))%mod;
	w[0]=1;
	w[1]=-1;
	g[0][0][0]=1;
	for(int i=1;i<=n;++i)
	{
		for(int j=0;j<=min(1ll*(i-1),m);++j)
			for(int z=0;z<=j;++z)
			{
				if(z!=0) dp[j][z][1]=(dp[j-1][z-1][0]+(w[(z%2)]*a[i]*g[j-1][z-1][0]%mod))%mod,g[j][z][1]=g[j-1][z-1][0];
				else dp[j][z][1]=(dp[j][z][0]+(w[(z%2)]*a[i]*g[j][z][0]%mod))%mod,g[j][z][1]=g[j][z][0];
			}
		for(int j=0;j<=m;++j)
			for(int z=m;z>=0;--z)
				dp[j][z][0]=(dp[j][z][1]+dp[j][z+1][0])%mod,g[j][z][0]=(g[j][z][1]+g[j][z+1][0])%mod,dp[j][z][1]=g[j][z][1]=0;
	}
	cout<<(dp[m][0][0]+mod)%mod*ksm(g[m][0][0]+mod)%mod,mod-2)%mod;	
	return 0;
}
